<script>
	import { saveLogin, checkLogin, getTicket } from '@/utils/auth.js';
	import request from '@/utils/request.js';
	
	export default {
		onLaunch: function() {
			const url = new URL(window.location.href);
			const ticket = url.searchParams.get('ticket');
			if (ticket && !getTicket()) {
				saveLogin(ticket);
			}
			if (checkLogin()) {
				request.post('/v2/getuserinfobyticket', {}).then(res => {
					const [data, err] = res;
					if (!err) {
						this.$store.commit('m_user/saveUserInfo', data);
					}
				});
			} else {
				// 引导登录
				uni.navigateTo({
					url: '/pages/login/login'
				});
			}
		},
		onShow: function() {
		},
		onHide: function() {
			
		}
	}
</script>

<style  lang="scss">
	/*每个页面公共css */
		@import "uview-ui/index.scss";
</style>
